﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EF6DBFirst
{
    class Program
    {
        static void Main(string[] args)
        {
            using(var ctx = new HR_SQSZYYEntities())
            {
                var oca = ctx as IObjectContextAdapter;
                ObjectContext objContext = default;
                if(oca != null)
                {
                    objContext = oca.ObjectContext;
                }
                var realRxEntity = ctx.REAL_RX.FirstOrDefault(rx => rx.RX_ID > 20);
                Console.WriteLine($"处方的编号{realRxEntity.RX_ID}");
                realRxEntity.ENTERED_BY = "翟超";
                ctx.SaveChanges();
                Console.WriteLine(realRxEntity.GetType());
                Console.WriteLine(ObjectContext.GetObjectType(realRxEntity.GetType()));
            }
            Console.ReadKey();
        }
    }
}
